package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BObsvCfgService;
import top.tangyh.lamp.care.entity.BObsvCfg;
import top.tangyh.lamp.care.vo.query.DeleteBactchQuery;
import top.tangyh.lamp.care.vo.query.ObsvCfgQueryParam;
import top.tangyh.lamp.care.vo.result.ObsvCfgDto;
import top.tangyh.lamp.care.vo.result.ObsvCfgForRdDto;
import top.tangyh.lamp.care.vo.result.PageOutputDTO;
import top.tangyh.lamp.care.vo.save.BObsvCfgSaveVO;
import top.tangyh.lamp.care.vo.update.BObsvCfgUpdateVO;
import top.tangyh.lamp.care.vo.result.BObsvCfgResultVO;
import top.tangyh.lamp.care.vo.query.BObsvCfgPageQuery;
import top.tangyh.lamp.common.constant.CommonConstant;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * 观察项配置主表
 * </p>
 *
 * @author zqb
 * @date 2024-07-26 11:20:21
 * @create [2024-07-26 11:20:21] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/obsvCfg")
@Tag(name = "观察项配置")
public class BObsvCfgController {
//    extends SuperController<BObsvCfgService, Long, BObsvCfg
//            , BObsvCfgSaveVO, BObsvCfgUpdateVO, BObsvCfgPageQuery, BObsvCfgResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    private final BObsvCfgService bObsvCfgService;

    @Operation(summary = "分页查询观察项配置")
    @PostMapping("/list")
    public R<PageOutputDTO<ObsvCfgDto>> query(@Valid @RequestBody ObsvCfgQueryParam param) {
        return R.success(bObsvCfgService.queryPage(param));
    }

    @Operation(summary = "查询(用于观察项记录)")
    @PostMapping("/listForRd")
    public R<List<ObsvCfgForRdDto>> queryForRd(@Valid @RequestBody ObsvCfgQueryParam param) {
        param.setIsVisible(CommonConstant.YES_NUMBER);
        return R.success(bObsvCfgService.queryForRd(param));
    }

    @Operation(summary = "保存观察项")
    @PostMapping("/save")
    public R<ObsvCfgDto> create(@Valid @RequestBody ObsvCfgDto param) {
        return R.success(bObsvCfgService.insertOrUpdate(param));
    }

    @Operation(summary = "批量删除观察项")
    @DeleteMapping("/deletebatch")
    public R<Boolean> delete(@Valid @RequestBody DeleteBactchQuery param) {
        return R.success(bObsvCfgService.removeByIds(param.getIds()));
    }

}


